package net.linku.annotation;

import lombok.Getter;

import java.util.Arrays;

public class ChangeRecordEnums {

    @Getter
    public enum TYPE {
        // 示例
        ADMIN_PRIVILEGE("ADMIN_PRIVILEGE", "权限数据"),
        ADMIN_ROLE("ADMIN_ROLE", "菜单数据");

        private final String type;
        private final String desc;

        TYPE(String type, String desc) {
            this.type = type;
            this.desc = desc;
        }

        public static TYPE matchTypeEnum(String businessType) {
            return Arrays.stream(TYPE.values())
                    .filter(enumType -> enumType.getType().equalsIgnoreCase(businessType))
                    .findFirst()
                    .orElse(null);
        }
    }

    @Getter
    public enum CHANGE_TYPE {
        INSERT("add", "新增"),
        MODIFY("modify", "修改"),
        DELETE("delete", "删除"),
        IMPORT("import", "导入"),
        RETRY("retry", "重新推送"),
        APPROVED("approved", "审核"),
        SUBMIT("submit", "提交"),
        CLOSE("close", "关单"),
        ACCEPT("accept", "接单"),
        DELIVERY("delivery", "发货"),
        PUSH("push", "下推"),
        CONFIRM("confirm", "确认"),
        SAVE("save", "保存");
        private final String type;
        private final String desc;

        CHANGE_TYPE(String type, String desc) {
            this.type = type;
            this.desc = desc;
        }

        public static CHANGE_TYPE matchTypeEnum(String changeType) {
            return Arrays.stream(CHANGE_TYPE.values())
                    .filter(enumType -> enumType.getType().equalsIgnoreCase(changeType))
                    .findFirst()
                    .orElse(null);
        }
    }

    @Getter
    public enum ACTION {
        INSERT("insert", "新增"),
        MODIFY("modify", "修改"),
        DELETE("delete", "删除"),
        INSERT_OR_MODIFY("insertOrModify", "新增和更新");

        private final String action;
        private final String desc;

        ACTION(String action, String desc) {
            this.action = action;
            this.desc = desc;
        }

        public static ACTION matchTypeEnum(String action) {
            return Arrays.stream(ACTION.values())
                    .filter(enumType -> enumType.getAction().equalsIgnoreCase(action))
                    .findFirst()
                    .orElse(null);
        }
    }
}